import random
def remember(answer,result,aquestion,aw,wrong_answer):
    while answer!=-1:
        x=random.randint(0,len(result)-1)
        if x not in aquestion:
            aquestion.append(x)
            print('中文：'+result[x][1])
            answer=input('英文(输入‘-1’结束)：')
            while aw==0:
                if answer==result[x][0]:
                    print('-----------------正确-----------------')
                    print('\n')
                    aw=1
                if answer!=result[x][0]:
                    print('-----------------错误-----------------')
                    if [result[x][0],result[x][1]] not in wrong_answer:
                        wrong_answer.append([result[x][0],result[x][1]])
                    answer=input('重新输入（‘0’查看答案）：')
                    if answer=='0':
                        print('-----------------答案-----------------')
                        print(result[x][0])
                        print('\n')
                        aw=1
            aw=0
        if len(aquestion)==len(result):
            if len(wrong_answer)!=0:
                result=wrong_answer
                wrong_answer=[]
                aquestion=[]
                print('错误单词如下：')
                print(result)
                print('开始复习错误单词！！！')
                print('\n')
                remember(answer,result,aquestion,aw,wrong_answer)
            answer=-1
    
with open('C:/Users/DP/Desktop/单词文本.txt') as f:
    result=[]
    aquestion=[]
    f=f.read()
    a=f.split('\n')
    answer=0
    aw=0
    wrong_answer=[]
    for i in a:
        b=str(i).split('，')
        for j in b:
            c=str(j).split('/')
            result.append(c)
    remember(answer,result,aquestion,aw,wrong_answer)
    print('复习完毕!!')
        
